<!--$Id: db_exists.so,v 1.1 2007/07/12 18:27:42 bostic Exp $-->
<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB: DB-&gt;exists</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<table width="100%"><tr valign=top>
<td>
<b>DB-&gt;exists</b>
</td>
<td align=right>
<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a>
<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td>
</tr></table>
<hr size=1 noshade>
<tt>
<b><pre>
#include &lt;db.h&gt;
<p>
int
DB-&gt;exists(DB *db, DB_TXN *txnid, DBT *key, u_int32_t flags);
</pre></b>
<hr size=1 noshade>
<b>Description: DB-&gt;exists</b>
<p>The DB-&gt;exists method returns if the specified key appears in the
database.</p>
<p>The DB-&gt;exists method will return <a href="../ref/program/errorret.html#DB_NOTFOUND">DB_NOTFOUND</a> if the specified key is not in the database.
The DB-&gt;exists method will return <a href="../ref/program/errorret.html#DB_KEYEMPTY">DB_KEYEMPTY</a> if the database is a Queue or Recno database and
the specified key exists, but was never explicitly created by the
application or was later deleted.
Unless otherwise specified, the DB-&gt;exists method
returns a non-zero error value on failure
and 0 on success.
</p>
<b>Parameters</b> <br>
 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or
one of the following values:
In addition, the following flags may be set by
bitwise inclusively <b>OR</b>'ing them into the <b>flags</b> parameter:
<br>
<b><a name="DB_READ_COMMITTED">DB_READ_COMMITTED</a></b><ul compact><li>Configure a transactional read operation to have degree 2 isolation (the
read is not repeatable).</ul>
<b><a name="DB_READ_UNCOMMITTED">DB_READ_UNCOMMITTED</a></b><ul compact><li>Configure a transactional read operation to have degree 1 isolation,
reading modified but not yet committed data.  Silently ignored if the
<a href="../api_c/db_open.html#DB_READ_UNCOMMITTED">DB_READ_UNCOMMITTED</a> flag was not specified when the underlying
database was opened.</ul>
<b><a name="DB_RMW">DB_RMW</a></b><ul compact><li>Acquire write locks instead of read locks when doing the read, if
locking is configured.  Setting this flag can eliminate deadlock during
a read-modify-write cycle by acquiring the write lock during the read
part of the cycle so that another thread of control acquiring a read
lock for the same item, in its own read-modify-write cycle, will not
result in deadlock.
<p>Because the DB-&gt;exists method will not hold locks across
Berkeley DB calls in non-transactional operations, the <a href="../api_c/dbc_get.html#DB_RMW">DB_RMW</a> flag to
the DB-&gt;exists call is meaningful only in the presence of
transactions.</p></ul>
<br></ul>
 <b>key</b><ul compact><li>The key <a href="../api_c/dbt_class.html">DBT</a> operated on.</ul>
 <b>txnid</b><ul compact><li>If the operation is part of an application-specified transaction, the
<b>txnid</b> parameter is a transaction handle returned from
<a href="../api_c/txn_begin.html">DB_ENV-&gt;txn_begin</a>; if the operation is part of a Berkeley DB Concurrent Data Store group, the
<b>txnid</b> parameter is a handle returned from
<a href="../api_c/env_cdsgroup_begin.html">DB_ENV-&gt;cdsgroup_begin</a>; otherwise NULL.
</ul>
<br>
<hr size=1 noshade>
<br><b>Class</b>
<a href="../api_c/db_class.html">DB</a>
<br><b>See Also</b>
<a href="../api_c/db_list.html">Databases and Related Methods</a>
</tt>
<table width="100%"><tr><td><br></td><td align=right>
<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
</td></tr></table>
<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
</body>
</html>
